package com.rjgc.title.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.rjgc.title.common.util.DateUtil;
import com.rjgc.title.mapper.DeclareMapper;
import com.rjgc.title.model.entity.apply.Declare;
import com.rjgc.title.service.DeclareService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 申报表 服务实现类
 * </p>
 *
 * @author 卓抱抱
 * @since 2022-04-26
 */
@Service
public class DeclareServiceImpl extends ServiceImpl<DeclareMapper, Declare> implements DeclareService {

    @Autowired
    private DeclareMapper declareMapper;

    @Override
    public Declare getByUserId(String userId) {

        QueryWrapper<Declare> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("userId",userId);
        String year = DateUtil.getYear(new Date());
        queryWrapper.eq("year",year);

        Declare declare = declareMapper.selectOne(queryWrapper);
        return declare;
    }
}
